<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="IngresoOT.aspx.cs" Inherits="Gestion_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="contenido" Runat="Server">
    &nbsp;<asp:Panel ID="pnlFacturas" runat="server" Width="100%" GroupingText="Ordenes de trabajo">
    <script language="javascript" type="text/javascript">
function intOnly(i) 
{
if(i.value.length>0) 
{
i.value = i.value.replace(/[^\d]+/g, ''); 
}
}
</script>
        <br />
        &nbsp;<table width="100%">
            <tr>
                <td align="left" colspan="2" style="height: 14px; text-align: left" valign="top">
                    <strong>Datos generales<br />
                    </strong>
                </td>
                <td align="left" colspan="1" style="width: 100px; height: 14px; text-align: left"
                    valign="top">
                    <a href="../Impresiones/inventario.aspx" target="popup" onClick="window.open(this.href, this.target, 'width=800,height=1000'); return false;">Imprimir</a>
                </td>
                <td align="left" colspan="1" style="width: 400px; height: 14px; text-align: left"
                    valign="top">
                </td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="text-align: right; width: 100px;" valign="top">
                    Numero OT :</td>
                <td align="left" colspan="1" valign="top" style="width: 215px">
                    <asp:TextBox ID="txbNumero" runat="server" onChange="intOnly(this);" onkeypress="intOnly(this);"
                        onkeyup="intOnly(this);" Width="200px"></asp:TextBox>
                    </td>
                <td align="left" colspan="1" style="width: 100px" valign="top">
                    <asp:CustomValidator ID="cvlNumero" runat="server" ControlToValidate="txbNumero"
                        ErrorMessage="Numero ya existe." ValidationGroup="Aceptar"></asp:CustomValidator></td>
                <td align="left" colspan="1" rowspan="12" style="width: 400px" valign="top">
                    <asp:GridView ID="gdvOrdenesDeTrabajo" runat="server" AutoGenerateColumns="False"
                        Width="100%" DataKeyNames="Id" OnSelectedIndexChanged="gdvOrdenesDeTrabajo_SelectedIndexChanged">
                        <Columns>
                            <asp:TemplateField HeaderText="N&#176;" SortExpression="NumeroOrdenDeTrabajo">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NumeroOrdenDeTrabajo") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("NumeroOrdenDeTrabajo") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Fecha" SortExpression="Fecha">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Fecha") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Fecha", "{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Cliente" SortExpression="Cliente">
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("[Cliente.RazonSocial]") %>'></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("Cliente.RazonSocial") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:CommandField SelectText="Seleccionar" ShowSelectButton="True" />
                        </Columns>
                        <RowStyle CssClass="RowStyle" />
        <PagerStyle CssClass="PagerStyle" />
        <HeaderStyle CssClass="HeaderStyle" />
        <AlternatingRowStyle CssClass="AltRowStyle" />
        <SelectedRowStyle CssClass="SelectedRowStyle" />
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="text-align: right; width: 100px;" valign="top">
                    Cliente :</td>
                <td align="left" colspan="1" valign="top" style="text-align: left; width: 215px;">
                    <asp:DropDownList ID="ddlCliente" runat="server" Width="200px">
                    </asp:DropDownList>
                    *</td>
                <td align="left" colspan="1" style="width: 100px; text-align: left" valign="top">
                    <asp:CompareValidator ID="CompareValidator5" runat="server" ControlToValidate="ddlCliente"
                        ErrorMessage="Requerido" Operator="NotEqual" ValidationGroup="Aceptar" ValueToCompare="0"></asp:CompareValidator></td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                </td>
                <td align="left" colspan="1" style="width: 215px; text-align: left" valign="top">
                    <asp:TextBox ID="txbDescripcion" runat="server" Rows="5" TextMode="MultiLine" Width="200px"></asp:TextBox>*</td>
                <td align="left" colspan="1" style="width: 100px; text-align: left" valign="top">
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txbDescripcion"
                        ErrorMessage="Requerido" ValidationGroup="Aceptar"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                </td>
                <td align="left" colspan="1" style="width: 215px; text-align: left" valign="top">
                    <asp:Button ID="btnNuevo" runat="server" Text="Nuevo" CssClass="botonNuevo" OnClick="btnNuevo_Click" />
                    <asp:Button ID="btnEliminar" runat="server" Text="Eliminar" CssClass="botonEliminar" OnClick="btnEliminar_Click" Enabled="False" /></td>
                <td align="left" colspan="1" style="width: 100px; text-align: left" valign="top">
                </td>
            </tr>
            <tr>
                <td align="left" colspan="2" style="text-align: left" valign="top">
                    <hr />
                    <strong>Productos Asociados<br />
                    </strong>
                </td>
                <td align="left" colspan="1" style="width: 100px; text-align: left" valign="top">
                </td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                    Familia :</td>
                <td align="left" colspan="1" style="width: 215px; text-align: left" valign="top">
                    <asp:DropDownList ID="ddlFamilia" runat="server" AutoPostBack="True" Width="200px" OnSelectedIndexChanged="ddlFamilia_SelectedIndexChanged">
                    </asp:DropDownList>
                    *</td>
                <td align="left" colspan="1" style="width: 100px; text-align: left" valign="top">
                    <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="ddlFamilia"
                        ErrorMessage="Seleccione" Operator="NotEqual" ValidationGroup="Agregar" ValueToCompare="0"></asp:CompareValidator></td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                    Producto :</td>
                <td align="left" colspan="1" style="width: 215px; text-align: left" valign="top">
                    <asp:DropDownList ID="ddlProducto" runat="server" Width="200px" AutoPostBack="True" OnSelectedIndexChanged="ddlProducto_SelectedIndexChanged">
                    </asp:DropDownList>
                    *</td>
                <td align="left" colspan="1" style="width: 100px; text-align: left" valign="top">
                    <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="ddlProducto"
                        ErrorMessage="Seleccione" Operator="NotEqual" ValidationGroup="Agregar" ValueToCompare="0"></asp:CompareValidator></td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                    Cantidad :</td>
                <td align="left" colspan="1" style="width: 215px; text-align: left" valign="top">
                    <asp:TextBox ID="txbCantidad" runat="server" Width="200px" onChange="intOnly(this);" onKeyUp="intOnly(this);" onKeyPress="intOnly(this);"></asp:TextBox>
                    *</td>
                <td align="left" colspan="1" style="width: 100px; text-align: left" valign="top">
                    <asp:RequiredFieldValidator ID="rfvCantidad" runat="server" ControlToValidate="txbCantidad"
                        ErrorMessage="Requerido" ValidationGroup="Agregar"></asp:RequiredFieldValidator></td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                </td>
                <td align="left" colspan="1" style="width: 215px; text-align: left" valign="top">
                    <asp:Button ID="btnAgregar" runat="server" Text="Agregar" CssClass="botonAceptar" OnClick="btnAgregar_Click" ValidationGroup="Agregar" />
                    <asp:Button ID="btnAceptar" runat="server" Text="Finalizar" CssClass="botonFinalizado" OnClick="botonAceptar_Click" ValidationGroup="Aceptar" /></td>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                </td>
            </tr>
            <tr>
                <td align="left" colspan="3" style="text-align: right" valign="top">
                    <asp:DataList ID="dtlDetalleOrdenDeTrabajo" runat="server" Width="100%" OnSelectedIndexChanged="dtlDetalleOrdenDeTrabajo_SelectedIndexChanged">
                        <HeaderTemplate>
                            <table width="100%" class="ItemTemplate">
                                <tr>
                                    <td style="width: 60%; text-align: left" class="HeaderStyle">
                                        Producto</td>
                                    <td style="width: 20%; text-align: left" class="HeaderStyle">
                                        Cantidad</td>
                                    <td style="width: 20%; text-align: left" class="HeaderStyle">
                                    </td>
                                </tr>
                            </table>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <table style="border-right-style: none; border-right-color: black" width="100%">
                                <tr>
                                    <td style="width: 60%; text-align: left">
                                        <asp:Label ID="ProductoLabel" runat="server" Text='<%# Eval("Producto.Descripcion") %>'></asp:Label></td>
                                    <td align="right" style="width: 20%; text-align: right; border-right-color: gray;">
                                        <asp:Label ID="CantidadIngresoLabel" runat="server" Text='<%# Eval("Cantidad") %>'></asp:Label></td>
                                    <td align="right" style="width: 20%; text-align: right">
                                        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="btnBorrar_Click" CommandArgument='<%# Eval("Producto.Id") %>'>Eliminar</asp:LinkButton>&nbsp;</td>
                                </tr>
                            </table>
                        </ItemTemplate>
                        <SeparatorStyle BorderColor="Black" BorderStyle="Solid" />
                    </asp:DataList></td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                    </td>
                <td align="left" colspan="1" valign="top" style="width: 215px">
                    </td>
                <td align="left" colspan="1" style="width: 100px" valign="top">
                </td>
            </tr>
            <tr>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                </td>
                <td align="left" colspan="1" style="text-align: right; width: 215px;" valign="top">
                </td>
                <td align="left" colspan="1" style="width: 100px; text-align: right" valign="top">
                </td>
            </tr>
        </table>
    </asp:Panel>
    &nbsp; &nbsp;
    &nbsp; &nbsp;&nbsp;
</asp:Content>

